package net.wicp.tams.commons.callback.impl.column;

import java.util.Date;

import org.apache.tapestry5.json.JSONObject;

import net.wicp.tams.commons.callback.ICol;
import net.wicp.tams.commons.constant.DateFormatCase;

public class ColDateTime implements ICol<Date> {
	private static final long serialVersionUID = 1L;
	private final Date date;

	public ColDateTime(Date date) {
		this.date = date;
	}

	@Override
	public String toClient() {
		return DateFormatCase.YYYY_MM_DD_hhmmss.getInstanc().format(date);
	}

	@Override
	public Date toValue() {
		return date;
	}

	@Override
	public JSONObject toJson(String colName) {
		return new JSONObject(colName, toClient());
	}
}
